package com.example.study.jetpack.compose


import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

/**
 *  created by 20300
 *   on 2022/3/9
 *   describe:https://blog.csdn.net/Mr_Tony/article/details/118875010?spm=1001.2014.3001.5502
 */
class Compose的主题Theme {
    /*在Android可以对整个应用得风格进行管理,这种风格叫做主题.通过主题对整个应用的字体,颜色,大小,形状
    * 进行管理可以使得整个应用的规范,并且以后都按照这个规范来进行开发.不过主题实际使用场景不大
    *
    * 材质主题
    * jetpack Compose 提供了Material Design的实现MaterialTheme  一个用于创建数字
    * 界面的综合设计系统
    * 对于MaterialTheme的简单使用如下
    * 示例:
    *  */
    @Composable
    private fun theme(){

        val lightColors = lightColors(
            primary = Color(0xFF1EB980)
        )

        val darkColors = darkColors(
            primary = Color(0xFF66ffc7)
        )

        val colors = if (isSystemInDarkTheme()) darkColors else lightColors

        val typography = Typography(
            h1 = TextStyle(
                fontWeight = FontWeight.W100,
                fontSize = 96.sp
            ),
            button = TextStyle(
                fontWeight = FontWeight.W600,
                fontSize = 14.sp
            )
        )

        MaterialTheme(colors = colors, typography = typography) {
            val currentTheme = if (MaterialTheme.colors.isLight) "light" else "dark"
            ExtendedFloatingActionButton(
                text = { Text("FAB with text style and color from $currentTheme theme") },
                onClick = {}
            )
        }
    }

    /*自定义属性主题:
    * 如果系统默认主题不能满足需求时候可以自己配置主题
    * 示例:*/
    private val DarkColors = darkColors(
        primary = Color.Cyan,
        primaryVariant = Color.Cyan,
        secondary = Color.Cyan
    )

    private val LightColors = lightColors(
        primary = Color.Magenta,
        primaryVariant = Color.Magenta,
        secondary = Color.Magenta
    )

    @Composable
    fun BasicsCodelabTheme(
        darkTheme: Boolean = isSystemInDarkTheme(),
        content: @Composable () -> Unit
    ) {
        val colors = if (darkTheme) {
            DarkColors
        } else {
            LightColors
        }

        MaterialTheme(colors = colors) {
            content()
        }
    }
    /*如果涉及到一件换肤的功能可以使用状态的机制来修改整个应用的主题*/


}